package servlets;
import java.sql.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Connectivity.ConnectionManager;
 

/**
 * Servlet implementation class LoginServlet
 */
public class MasterServlet extends HttpServlet {


	/**
	 * 
	 */
	private static final long serialVersionUID = 4539306437776063184L;

	public void doGet(HttpServletRequest request, HttpServletResponse response) 
				           throws ServletException, java.io.IOException {

		String groupcode=null;
		String groupname=null;
	
	try
	{	    

		//groupcode=123&groupname=23423
		groupcode=(request.getParameter("groupcode"));
		groupname=(request.getParameter("groupname"));
	    Connection con=null;
	
		
		con=ConnectionManager.getConnection();
		String query="Insert into item_group_master(group_id,group_code,group_name,status) values(nextval('item_group_master_seq'),?,?,'V')";
		PreparedStatement prst=con.prepareStatement(query);
	 	prst.setString(1,groupcode);
		prst.setString(2,groupname);
	    prst.execute();
	          
	    response.sendRedirect("/Genius/form/masters/GroupCreation.jsp"); //logged-in page  
	 
	     
	} 
			
			
	catch (Throwable theException) 	    
	{
	     System.out.println(theException); 
	}
	       }
}